package com.cloud.example.config;

import com.cloud.async.flow.web.client.FlowTemplate;
import com.cloud.example.config.tx.JpaTransactionSourceFlow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * stater自定义配置非默认自动配置
 * @author chengr 2021-11-12
 */
@SpringBootApplication
public class WebFlowConfiguration {


    @Autowired
    public Executor executor;

    @Autowired
    JpaTransactionSourceFlow JpaTransactionSourceFlow;

    /**
     * 多线程任务编排（事务）
     * @return
     */
    @Bean
    FlowTemplate flowTemplate() {
        return new FlowTemplate(Executors.newCachedThreadPool(), JpaTransactionSourceFlow);
    }



//    多线程任务编排（不带事务）
//    @Bean
//    AsyncFlowTemplate asyncFlowTemplate() {
//        return new AsyncFlowTemplate(Executors.newCachedThreadPool());
//    }


}
